package com.iversonx.adapter.example_1.remote.db;

import com.iversonx.adapter.model.LogData;
import com.iversonx.adapter.example_1.domain.LogModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author Lijie
 * @version 1.0
 * @date 2019/11/20 19:20
 */
@Service
public class LogDbOperate implements LogDbOperateApi {
    private final static Logger LOGGER = LoggerFactory.getLogger(LogDbOperate.class);
    
    @Override
    public void insertLog(LogModel log) {
        LogData.DATA.put(log.getLogId(), log);
        LOGGER.info("记录日志到数据库");
    }
    
    @Override
    public Map<String, LogModel> mapLog() {
        LOGGER.info("从数据库中读取日志列表");
        return LogData.DATA;
    }
    
    @Override
    public LogModel get(String logId) {
        LOGGER.info("从数据库读取单条日志");
        return LogData.DATA.get(logId);
    }
}
